<?php
class Model_test extends CI_Model {

	public function __construct()
    {
        $this->load->database();
    }
	
	public function get_soal($jenis_test_id)
    {
		$this->db->select('*');
		$this->db->from('soal');
		$this->db->where('jenis_test_id', $jenis_test_id);
		$this->db->order_by('id', 'Asc');
		$query = $this->db->get();
		
		return $query->result_array();
	}
	
	public function get_jenis_test()
    {
		$this->db->select('*');
		$this->db->from('jenis_test');
		$this->db->where('status', '1');
		$this->db->order_by('id', 'Desc');
		$query = $this->db->get();
		
		return $query->result_array(); 	
    }
	
	function simpan_jawaban($data)
    {
		$insert = $this->db->insert('jawaban_user', $data);
		
	    return $insert;
	}
	
	function check_user($id_user,$id_test){
		$this->db->select('id_user');
		$this->db->from('jawaban_user');
		$this->db->where('id_user', $id_user);
		$this->db->where('id_test', $id_test);
		$query = $this->db->get();
		
		return $query->num_rows();
	}

}